package com.jiangxjsy.model;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * wukong-crm-master
 * 蒋胜宇
 * 2025/6/3 23:19
 */

public class ModelApplication {
    public static class Content implements Serializable {
        public String[][] letters;
        public String message;
        public String word;
        public String author;
    }

    public static void main(String[] args) {
        String name = ModelApplication.class.getSimpleName();
        String file = name.replaceAll("(.)([A-Z])", "$1.$2").toLowerCase();

        Content content = null;
        try (ObjectInputStream ois = new ObjectInputStream(
                Files.newInputStream(Paths.get(file))
        )) {
            content = (Content) ois.readObject();
        } catch (IOException | ClassNotFoundException ignore) {
            System.exit(1);
        }
        String[][] letters = content.letters;
        String message = content.message;
        String word = content.word;
        String author = content.author;

        int length = message.length() * 3;
        for (int i = 1; i <= length; i++) {
            System.out.print("*");
            if (i % length == 0) System.out.println();
        }
        for (int i = 1; i <= length; i++) {
            if (i <= length / 3) {
                System.out.print(" ");
            } else if (i <= length * 2 / 3) {
                System.out.print(message.charAt(i - length / 3 - 1));
            } else {
                System.out.print(" ");
            }
            if (i % length == 0) System.out.println();
        }
        for (int i = 1; i <= length; i++) {
            System.out.print("*");
            if (i % length == 0) System.out.println();
        }
        System.out.println();
        int a = (word.length() * 5) + (word.length() - 1);
        for (int line = 0; line < 5; line++) {
            for (int i = 1; i <= (length - a) / 2; i++) {
                System.out.print(" ");
            }
            for (char c : word.toCharArray()) {
                int index = c - 'A';
                if (index >= 0 && index < letters.length) {
                    System.out.print(letters[index][line] + "  ");
                } else {
                    System.out.print("?????  ");
                }
            }
            System.out.println();
        }
        System.out.println();
        int b = author.length();
        for (int i = 1; i <= length; i++) {
            System.out.print("*");
            if (i % length == 0) System.out.println();
        }
        for (int i = 1; i <= (length - b) / 2; i++) {
            System.out.print(" ");
        }
        System.out.println(author);
        for (int i = 1; i <= length; i++) {
            System.out.print("*");
            if (i % length == 0) System.out.println();
        }
    }
}
